using dbvc.context;
using dbvc.context.User;
using dbvc.data;
using dbvc.Queries;
using NUnit.Framework;

namespace tdd.dbvc
{
    public partial class tests
    {
        [TearDown]
        [Category("general")]
        public void tear_down()
        {
            del_users();
            del_activity();
            del_projects();
            del_script();
            del_version();
            del_assignments();
            detach_all();

            logout();
        }
        
        [Test]
        [Category("user")]
        public void add_users()
        {
            root_login();

            del_users();

            del_activity();

            new CreateUser(security.Principal, new db_user() { name = "X1", pass = "X1" }).Execute();
            new CreateUser(security.Principal, new db_user() { name = "X2", pass = "X2" }).Execute();
            new CreateUser(security.Principal, new db_user() { name = "X3", pass = "X3" }).Execute();

            Assert.AreEqual(4, GenericQuery<db_user>.Count());
        }

        [Test]
        [Category("user")]
        public void del_users()
        {
            root_login();

            new DeleteUser(security.Principal, GenericQuery<db_user>.GetAll()).Execute();

            Assert.AreEqual(GenericQuery<db_user>.Count(), 1);
        }
    }
}